package com.tourlaid.mamagerment.ao.wx.impl

import com.github.pagehelper.Page
import com.github.pagehelper.PageHelper
import com.tourlaid.mamagerment.ao.wx.MyAttentionAo
import com.tourlaid.mamagerment.entity.ResponseData
import com.tourlaid.mamagerment.service.AttentionService
import com.tourlaid.mamagerment.service.StoreService
import com.tourlaid.mamagerment.util.LoginUtil
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import javax.annotation.Resource

/**
 * Created by xiaoyongge on 2017/8/31.
 */
@Service("myAttentionAo")
class MyAttentionAoImpl : MyAttentionAo {


    @Resource
    val attentionService: AttentionService? = null
    @Resource
    val storeService: StoreService? = null

    override fun queryData(pageNo: Int): ResponseData<List<Map<String, Any?>>> {
        PageHelper.startPage<Map<String, Any?>>(pageNo, 20, true)
        var page = attentionService!!.queryByUserId(LoginUtil.userId!!) as Page<Map<String, Any?>>
        var responseData = ResponseData(page.getResult())
        responseData.totalCount = page.getTotal()
        return responseData
    }

    @Transactional
    override fun delete(thoughtId: Long) {
//        val thought = thoughtService!!.getById(thoughtId);
//        if (!Objects.equals(thought.userId, LoginUtil.userId)) {
//            throw TldException(TldExceptionEnum.OTHER_THOUGHT)
//        }
//        thoughtService!!.delete(thoughtId)
//        //修改店铺的说说数
//        storeService!!.minusWhenThoughtDel(thought.storeId)
    }
}